package com.stylefeng.guns.modular.hhtb.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.common.constant.factory.PageFactory;
import com.stylefeng.guns.modular.hhtb.model.LogHhtbcDTO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.modular.hhtb.model.LogHhtbc;
import com.stylefeng.guns.modular.hhtb.service.ILogHhtbcService;

import java.util.List;

/**
 * 猫币APPHHTB流水控制器
 *
 * @author fengshuonan
 * @Date 2018-09-15 17:05:14
 */
@Controller
@RequestMapping("/logHhtbc")
public class LogHhtbcController extends BaseController {

    private String PREFIX = "/hhtb/logHhtbc/";

    @Autowired
    private ILogHhtbcService logHhtbcService;

    /**
     * 跳转到猫币APPHHTB流水首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "logHhtbc.html";
    }

    /**
     * 跳转到添加猫币APPHHTB流水
     */
    @RequestMapping("/logHhtbc_add")
    public String logHhtbcAdd() {
        return PREFIX + "logHhtbc_add.html";
    }

    /**
     * 跳转到修改猫币APPHHTB流水
     */
    @RequestMapping("/logHhtbc_update/{logHhtbcId}")
    public String logHhtbcUpdate(@PathVariable Integer logHhtbcId, Model model) {
        LogHhtbc logHhtbc = logHhtbcService.selectById(logHhtbcId);
        model.addAttribute("item",logHhtbc);
        LogObjectHolder.me().set(logHhtbc);
        return PREFIX + "logHhtbc_edit.html";
    }

    /**
     * 获取猫币APPHHTB流水列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(LogHhtbcDTO logHhtbcDTO) {
        Page<LogHhtbcDTO> page = new PageFactory<LogHhtbcDTO>().defaultPage();
        List<LogHhtbcDTO> list = logHhtbcService.selectAll(page,logHhtbcDTO);
        page.setRecords(list);
        return super.packForBT(page);
    }

    /**
     * 新增猫币APPHHTB流水
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(LogHhtbc logHhtbc) {
        logHhtbcService.insert(logHhtbc);
        return SUCCESS_TIP;
    }

    /**
     * 删除猫币APPHHTB流水
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer logHhtbcId) {
        logHhtbcService.deleteById(logHhtbcId);
        return SUCCESS_TIP;
    }

    /**
     * 修改猫币APPHHTB流水
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(LogHhtbc logHhtbc) {
        logHhtbcService.updateById(logHhtbc);
        return SUCCESS_TIP;
    }

    /**
     * 猫币APPHHTB流水详情
     */
    @RequestMapping(value = "/detail/{logHhtbcId}")
    @ResponseBody
    public Object detail(@PathVariable("logHhtbcId") Integer logHhtbcId) {
        return logHhtbcService.selectById(logHhtbcId);
    }
}
